package com.huawei.hms.framework.network.restclient.hwhttp.model;

import com.huawei.hms.framework.common.Logger;
import java.lang.ref.WeakReference;
import okhttp3.internal.connection.RealConnection;

public class ConnectionInfo {
    private static final String TAG = "ConnectionInfo";
    private String host;
    private WeakReference<RealConnection> weakReferenceRealConnection;

    public ConnectionInfo(String str, RealConnection realConnection) {
        this.host = str;
        this.weakReferenceRealConnection = new WeakReference(realConnection);
    }

    public String getHost() {
        return this.host;
    }

    public boolean isHealthy(boolean z) {
        if (this.weakReferenceRealConnection == null) {
            return false;
        }
        RealConnection realConnection = (RealConnection) this.weakReferenceRealConnection.get();
        if (realConnection == null) {
            return false;
        }
        if (realConnection.isHealthy(z)) {
            Logger.v(TAG, "the host is : %s,and the connection is healthy!", this.host);
            return true;
        }
        Logger.v(TAG, "the host is : %s,but the connection is unhealthy!", this.host);
        return false;
    }
}
